package com.example.meimessage.favorite;

import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;

import com.example.meimessage.R;

public class Favorite_more_new extends Activity{
	private EditText et;
	private Intent mIntent;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		setContentView(R.layout.favorite_more_write);
		et=(EditText) findViewById(R.id.favorite_more_write_edit);
		mIntent=getIntent();
		ActionBar bar=getActionBar();
		bar.setTitle(mIntent.getStringExtra("title"));
		bar.setDisplayShowHomeEnabled(true);
		bar.setDisplayHomeAsUpEnabled(true);
		bar.setIcon(R.drawable.mx);
		et.setText(mIntent.getStringExtra("text"));
		super.onCreate(savedInstanceState);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.favorite_more_new, menu);
		return super.onCreateOptionsMenu(menu);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		if(item.getItemId() == android.R.id.home) {            
			setResult(0);
			this.finish();
			}
		if(item.getItemId()==R.id.favorite_menu_new_save){
			Intent intent=new Intent();
			intent.putExtra("text", et.getText().toString());
			intent.putExtra("position", mIntent.getIntExtra("position", -1));	
			setResult(1, intent);
			this.finish();
		}
		return super.onOptionsItemSelected(item);
	}

}
